package com.central.scheduler.dao.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.central.common.model.SuperEntity;
import com.central.scheduler.common.enums.*;
import lombok.Data;

import java.util.Date;

/**
 * @author Tindy
 * @date 2021/11/1
 * @describe
 */
@Data
@TableName("sch_command")
public class Command extends SuperEntity {

    /**
     * command type
     */
    @TableField("command_type")
    private CommandType commandType;

    /**
     * process definition code
     */
    @TableField("process_definition_code")
    private long processDefinitionCode;

    /**
     * user id
     */
    @TableField("user_id")
    private Long userId;
    private String username;
    /**
     * project id
     */
    @TableField("pro_id")
    private Long proId;
    private String proName;

    /**
     * command parameter, format json
     */
    @TableField("command_param")
    private String commandParam;

    /**
     * task depend type
     */
    @TableField("task_depend_type")
    private TaskDependType taskDependType;

    /**
     * failure strategy
     */
    @TableField("failure_strategy")
    private FailureStrategy failureStrategy;

    /**
     * warning type
     */
    @TableField("warning_type")
    private WarningType warningType;

    /**
     * warning group id
     */
    @TableField("warning_group_id")
    private Long warningGroupId;

    /**
     * schedule time
     */
    @TableField("schedule_time")
    private Date scheduleTime;

    /**
     * start time
     */
    @TableField("start_time")
    private Date startTime;

    /**
     * process instance priority
     */
    @TableField("process_instance_priority")
    private Priority processInstancePriority;

    /**
     * dry run flag
     */
    @TableField("dry_run")
    private int dryRun;

    @TableField("process_instance_id")
    private Long processInstanceId;

    @TableField("process_definition_version")
    private int processDefinitionVersion;

    public Command() {
        this.taskDependType = TaskDependType.TASK_POST;
        this.failureStrategy = FailureStrategy.CONTINUE;
        this.startTime = new Date();
    }

    public Command(
            CommandType commandType,
            TaskDependType taskDependType,
            FailureStrategy failureStrategy,
            long userId,
            String username,
            long proId,
            String proName,
            long processDefinitionCode,
            String commandParam,
            WarningType warningType,
            long warningGroupId,
            Date scheduleTime,
            Priority processInstancePriority,
            int dryRun,
            Long processInstanceId,
            int processDefinitionVersion
    ) {
        this.commandType = commandType;
        this.userId = userId;
        this.username=username;
        this.proId=proId;
        this.proName=proName;
        this.processDefinitionCode = processDefinitionCode;
        this.commandParam = commandParam;
        this.warningType = warningType;
        this.warningGroupId = warningGroupId;
        this.scheduleTime = scheduleTime;
        this.taskDependType = taskDependType;
        this.failureStrategy = failureStrategy;
        this.startTime = new Date();
        this.processInstancePriority = processInstancePriority;
        this.dryRun = dryRun;
        this.processInstanceId = processInstanceId;
        this.processDefinitionVersion = processDefinitionVersion;
    }
}


